﻿/*----------------------------------------------------------------
  //Copyright (C) 2012 赵国伟
  //文件功能描述：权限资源管理
  //创建人：赵国伟
  //生成时间：2012/03/18 12:15:00
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using Shopping.Common;
using Shopping.Model;
using Shopping.BLL;

public partial class Manage_PurviewResourceManage : BaseManagePage
{
    protected List<ResourceInfo> listOfRes;
    protected string CheckOptionOfOperates;
    protected string ResourceEnumString; //资源枚举字符串；

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            PurviewResourceManage bllRes = new PurviewResourceManage();
            listOfRes = bllRes.QueryAllRes(false,false);
            CheckOptionOfOperates = PurviewResourceManage.GetOperatesToCheckOption("chkOperateId", "", 5);
            ResourceEnumString = GenerateEnum(listOfRes);
        }
    }


    #region "生成资源枚举  by 赵国伟 2010-04-05"
    /// <summary>
    /// 生成资源枚举
    /// </summary>
    /// <param name="listOperate"></param>
    /// <returns></returns>
    public string GenerateEnum(List<ResourceInfo> listResource)
    {

        StringBuilder sb = new StringBuilder(2000);
        sb.Append("/*----------------------------------------------------------------\\r\\n");
        sb.Append("  //Copyright (C) 2011 " + Config.ShoppingName + " \\r\\n");
        sb.Append("  //文件名：ResourceEnum.cs\\r\\n");
        sb.Append("  //文件功能描述：资源枚举。\\r\\n");
        sb.Append("  //最后生成时间：" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\\r\\n");
        sb.Append("//----------------------------------------------------------------*/\\r\\n");
        sb.Append("using System;\\r\\n");
        sb.Append("using System.Collections.Generic;\\r\\n");
        sb.Append("using System.Linq;\\r\\n");
        sb.Append("using System.Text;\\r\\n");
        sb.Append("\\r\\n");

        sb.Append("namespace Shopping.Purview\\r\\n");
        sb.Append("{\\r\\n");

        sb.Append("    /// &ltsummary&gt \\r\\n");
        sb.Append("    /// 权限资源枚举  CreateDate:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\\r\\n");
        sb.Append("    /// &lt/summary&gt\\r\\n");
        sb.Append("    public enum ResourceEnum\\r\\n");
        sb.Append("    {\\r\\n");
        if (listResource != null)
        {
            for (int i = 0; i < listResource.Count; ++i)
            {
                sb.Append("        ");
                sb.Append(listResource[i].Res.ResourceName);
                sb.Append("=");
                sb.Append(listResource[i].Res.PurviewResourceID);
                if ((i + 1) < listResource.Count)
                {
                    sb.Append(",");
                }
                sb.Append("\\r\\n");
            }
        }

        sb.Append("    }\\r\\n");
        sb.Append("}\\r\\n");
        return sb.ToString();


    }
    #endregion



}